package com.usian.admin.controller;

import com.usian.common.aliyun.GreeTextScan;
import com.usian.common.aliyun.GreenImageScan;
import com.usian.common.fastdfs.FastDFSClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
public class CheckText {
    @Autowired
    private GreeTextScan greeTextScan;
    @Autowired
    private GreenImageScan greenImageScan;
    @Autowired
    private FastDFSClient fastDFSClient;
@RequestMapping("checktext")
    public Map testText() throws Exception{
        Map map = greeTextScan.greeTextScan("我是一个文本,冰毒买卖是违法的");
      return map;
    }
    @RequestMapping("checkimage")
    public Map testImage() throws Exception {
            ArrayList<byte[]> images = new ArrayList<>();
            File image = new File("E:\\课堂资料\\上课资料\\实训\\积云头条讲义\\积云头条讲义\\day06-kafka&阿里云内容检测三方接口\\资料\\图片\\ak47.jpg");
            FileInputStream fileInputStream = new FileInputStream(image);
            byte[] filecount = new byte[(int) image.length()];
            fileInputStream.read(filecount);
            images.add(filecount);
        /*byte[] image1 = fastDFSClient.download("group1", "M00/00/00/wKg6imKiDk6AR71fAA305C1-Qwc837.png");
        List<byte[]> images = new ArrayList<>();
        images.add(image1);*/
            Map map = greenImageScan.imageScan(images);

        return map;
    }

}
